import { articleCategoryService } from './../api/category';
import type { AxiosError } from 'axios';
import { categorys } from '@/models/article';
import { ElMessage } from 'element-plus';

export default function () {
  async function getCategory() {
    try {
      let result = await articleCategoryService()
      if (result && result.data.data != null) {
        categorys.value = result.data.data
      }
    } catch (error) {
      const err = <AxiosError>error
      ElMessage.error(err)
    }
  }
  return {
    getCategory
  }
}